package com.jomoo.common.ajax.service.impl;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.jomoo.common.ajax.dao.JqueryDao;
import com.jomoo.common.ajax.service.JqueryService;
import com.jomoo.common.exception.AjaxQueryException;
import com.jomoo.common.tools.DateTools;

/**
 * 
* @ClassName: JqueryServiceImpl 
* @Description: 下拉菜单逻辑接口实现
* @author sddm.haosc
* @date 2017年12月12日 上午10:40:38 
*
 */
@Service("jqueryServiceImpl")
@Transactional(rollbackFor = AjaxQueryException.class)
public class JqueryServiceImpl implements JqueryService
{

	@Resource
	public JqueryDao jqueryDao;
	DateTools dateTools = new DateTools();
	
	/**
	 * 获取所有产品分类
	 * @return
	 * @throws AjaxQueryException
	 */
	@SuppressWarnings("rawtypes")
	@Override
	public List getProducts(Integer iCustomerId) throws AjaxQueryException 
	{
		List proList = null;
		
		try
		{
			proList = jqueryDao.getProducts(iCustomerId);
		} 
		catch (Exception e)
		{
			new AjaxQueryException("获取所有产品分类异常："+e.getMessage());
		}
		return proList;
	}
	
	/**
	 * 获取所有产品分类规格
	 * @return
	 * @throws AjaxQueryException
	 */
	@SuppressWarnings("rawtypes")
	@Override
	public List getProductSpec(Integer iProId) throws AjaxQueryException 
	{
		List proList = null;
		
		try
		{
			proList = jqueryDao.getProductSpec(iProId);
		} 
		catch (Exception e)
		{
			new AjaxQueryException("获取所有产品分类规格异常："+e.getMessage());
		}
		return proList;
	}
	
	/**
	 * 获取所有一级城市(地址调用)
	 * @return
	 * @throws AjaxQueryException
	 */
	@SuppressWarnings("rawtypes")
	@Override
	public List getFirstCity() throws AjaxQueryException 
	{
		List fcityList = null;
		
		try
		{
			fcityList = jqueryDao.getFirstCity();
		} 
		catch (Exception e)
		{
			new AjaxQueryException("获取所有一级城市异常："+e.getMessage());
		}
		return fcityList;
	}
	
	/**
	 * 获取所有二级城市(地址调用)
	 * @return
	 * @throws AjaxQueryException
	 */
	@SuppressWarnings("rawtypes")
	@Override
	public List getSecondCity(Integer iSecCityid)throws AjaxQueryException 
	{
		List scityList = null;
		
		try
		{
			scityList = jqueryDao.getSecondCity(iSecCityid);
		} 
		catch (Exception e)
		{
			new AjaxQueryException("获取所有二级城市异常："+e.getMessage());
		}
		return scityList;
	}
	
	/**
	 * 获取所有客户
	 * @return
	 * @throws AjaxQueryException
	 */
	@SuppressWarnings("rawtypes")
	@Override
	public List getCustomers() throws AjaxQueryException
	{
		List customerList = null;
		
		try
		{
			customerList = jqueryDao.getCustomers();
		} 
		catch (Exception e)
		{
			new AjaxQueryException("获取所有客户异常："+e.getMessage());
		}
		return customerList;
	}
	
	/**
	 * 获取所有安装类型
	 * @return
	 * @throws Exception
	 */
	@SuppressWarnings("rawtypes")
	@Override
	public List getSetupType() throws AjaxQueryException
	{
		List repairList = null;
		
		try
		{
			repairList = jqueryDao.getSetupType();
		} 
		catch (Exception e)
		{
			new AjaxQueryException("获取所有安装类型异常："+e.getMessage());
		}
		return repairList;
	}
	
	/**
	 * 获取所有状态详情
	 * @return
	 * @throws Exception
	 */
	@SuppressWarnings("rawtypes")
	@Override
	public List getAllStates(String strStateName, String strAllFlag) throws AjaxQueryException
	{
		List stateList = null;
		
		try
		{
			stateList = jqueryDao.getAllStates(strStateName, strAllFlag);
		} 
		catch (Exception e)
		{
			new AjaxQueryException("获取所有状态详情异常："+e.getMessage());
		}
		return stateList;
	}
	
	/**
	 * 根据不同标识查询不同情况数量用于页面显示
	 * @param strFlag
	 * @param date
	 * @return
	 * @throws Exception
	 */
	@Override
	public Integer getScount(String strFlag) throws AjaxQueryException
	{
		Integer iCount = 0;
		
		try
		{
			iCount = jqueryDao.getScount(strFlag, DateTools.getStartDate(), DateTools.getEndDate());
		} 
		catch (Exception e)
		{
			new AjaxQueryException("获取所有数量异常："+e.getMessage());
		}
		return iCount;
	}
	
	/**
	 * 获取用于通知消息显示的条数判断
	 * @return
	 * @throws AjaxQueryException
	 */
	@Override
	public Integer getCountForShow() throws AjaxQueryException
	{
		Integer iCount = 0;
		try
		{
			iCount = jqueryDao.getWaitCountForShow(DateTools.getStartDate(), DateTools.getEndDate());
			
			iCount += jqueryDao.getFixCountForShow(DateTools.getStartDate(), DateTools.getEndDate());
		} 
		catch (Exception e)
		{
			new AjaxQueryException("获取所有数量异常："+e.getMessage());
		}
		return iCount;
	}
	
	/**
	 * 页面点击条数查询详情
	 * @param iFlag
	 * @return
	 * @throws Exception
	 */
	@SuppressWarnings("rawtypes")
	@Override
	public List getScountViews(Integer iFlag) throws AjaxQueryException
	{
		List cardList = null;
		try
		{
			cardList = jqueryDao.getScountViews(iFlag, DateTools.getStartDate(), DateTools.getEndDate());
		} 
		catch (Exception e)
		{
			new AjaxQueryException("获取所有数量详情异常："+e.getMessage());
		}
		return cardList;
	}
}
